' This BASIC Anywhere Machine program based on bplus' QB64 source code
' from this post in QB64 forums: https://forum.qb64.org/index.php?topic=4746.msg141621#msg141621
'
declare Sub drawEasterEgg (xc, yc, scale, radianAngle as double)
def fn_RGB32(p1,p2,p3) = p1 * 256^2 + p2 * 256 + p3
Const Xmax = 1200, Ymax = 1024
dim as integer y, x, top_scale
scale = 96
Screen 18
color &hFFFF00
print "This program will render 5 rows of 6 random Easter eggs." : print
print "The program will wait about 3 seconds before clearing" : print "the screen to render a new batch of Easter Eggs." : print
print "To pause the program and have time to view the current" : print "screenful of eggs, press any key on your keyboard." : print
print "Right-click on the image to access a context menu" : print "from which you can save or copy the image." : print
print "When you are ready to resume the program, press any key." : print
print "Now, press any key to start rendering Easter eggs."
while inkey$ = "" : wend
Screen 21
color &hFFFF00
'
Do
cls
For y = 100 To 900 Step 200
For x = 100 To 1100 Step 200
call drawEasterEgg(x, y, scale, rnd * 6.28 )
Next
Next
_delay 3
if inkey$ <> "" then
locate 63, 70 : print "P A U S E D"
do : loop until inkey$ = ""
while inkey$ = "" : wend
do : loop until inkey$ = ""
end if
Loop
'
Sub drawEasterEgg (xc, yc, scale, radianAngle as double)
dim thisColor as long
dim as double x, y, a, d, c
dim as integer this_x, this_y
dim as double r,g,b
r = Rnd: g = Rnd: b = Rnd
For this_x = -100 To 100 Step 1
For this_y = -100 To 100 Step 1
x = this_x / 100 : y = this_y / 100
If x < 0 Then c = c + .0005 Else c = c - .0005
If (x * x + (1.4 ^ x * 1.6 * y) ^ 2 - 1) <= .01 Then
If y > 0 Then
thisColor = fn_RGB32(int(128 * (1 - y) + 128 * (1 - y) * Sin(c * r)), int(128 * (1 - y) + 128 * (1 - y) * Sin(c * g)), int(127 * (1 - y) + 127 * (1 - y) * Sin(c * b)))
Else
thisColor = fn_RGB32(int(128 + 128 * Sin(c * r)), int(128 + 128 * Sin(c * g)), int(127 + 127 * Sin(c * b)))
End If
a = _Atan2(y, x)
d = scale * Sqr(x * x + y * y)
PSet (int(xc + d * Cos(a + radianAngle)), int(yc + d * Sin(a + radianAngle))), thisColor
End If
Next
Next
End Sub